#version 330 core

in vec3 Normal;
in vec3 Position;

out vec4 color;

uniform vec3 cameraPos;
uniform samplerCube skybox;
uniform mat4 skybox_rotation;

void main() {
  // reflect
  // vec3 I = normalize(Position - cameraPos);
  // vec3 R = reflect(I, normalize(Normal));
  // R = inverse(mat3(skybox_rotation)) * R;
  // color = texture(skybox, R);
  
  float ratio = 1.00 / 1.52;//Glass
  //  float ratio = 1.00 / 1.33;// Water
  //  float ratio = 1.00 / 1.309;// Ice
  //  float ratio = 1.00 / 2.42;// Diamond
  vec3 I = normalize(Position - cameraPos);
  vec3 R = refract(I, normalize(Normal), ratio);
  R = inverse(mat3(skybox_rotation)) * R;
  color = texture(skybox, R);
}  
